package net.xiduth.game.player.content;

import net.xiduth.cache.loaders.ItemDefinitions;
import net.xiduth.game.item.Item;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.QuestManager.Quests;

public class ItemConstants {

	public static int getDegradeItemWhenWear(int id) {
		// pvp armors
		if (id == 13958)
			return id + 2; // if you wear it it becomes corrupted LOL
		return -1;
	}

	// return amt of charges
	public static int getItemDefaultCharges(int id) {
		// pvp armors
		if (id == 13910 || id == 13913 || id == 13916 || id == 13919
				|| id == 13922 || id == 13925 || id == 13928 || id == 13931
				|| id == 13934 || id == 13937 || id == 13940 || id == 13943
				|| id == 13946 || id == 13949 || id == 13952)
			return 1500;
		if (id == 13960 || id == 13963 || id == 13966 || id == 13969
				|| id == 13972 || id == 13975)
			return 3000;
		if (id == 13860 || id == 13863 || id == 13866 || id == 13869
				|| id == 13872 || id == 13875 || id == 13878 || id == 13886
				|| id == 13889 || id == 13892 || id == 13895 || id == 13898
				|| id == 13901 || id == 13904 || id == 13907 || id == 13960)
			return 6000; // 1hour
		// nex armors
		if (id == 20137 || id == 20141 || id == 20145 || id == 20149
				|| id == 20153 || id == 20157 || id == 20161 || id == 20165
				|| id == 20169 || id == 20173)
			return 60000;
		return -1;
	}

	// return what id it degrades to, -1 for disapear which is default so we
	// dont add -1
	public static int getItemDegrade(int id) {
		if (id == 11285) // DFS
			return 11283;
		// nex armors
		if (id == 20137 || id == 20141 || id == 20145 || id == 20149
				|| id == 20153 || id == 20157 || id == 20161 || id == 20165
				|| id == 20169 || id == 20173)
			return id + 1;
		return -1;
	}

	public static int getDegradeItemWhenCombating(int id) {
		// nex armors
		if (id == 20135 || id == 20139 || id == 20143 || id == 20147
				|| id == 20151 || id == 20155 || id == 20159 || id == 20163
				|| id == 20167 || id == 20171)
			return id + 2;
		return -1;
	}

	public static boolean itemDegradesWhileHit(int id) {
		if (id == 2550)
			return true;
		return false;
	}

	public static boolean itemDegradesWhileWearing(int id) {
		String name = ItemDefinitions.getItemDefinitions(id).getName()
				.toLowerCase();
		if (name.contains("c. dragon") || name.contains("corrupt dragon"))
			return true;
		return false;
	}

	public static boolean itemDegradesWhileCombating(int id) {
		String name = ItemDefinitions.getItemDefinitions(id).getName()
				.toLowerCase();
		// nex armors
		if (name.contains("torva") || name.contains("pernix")
				|| name.contains("virtus") || name.contains("zaryte"))
			return true;
		return false;
	}

	public static boolean canWear(Item item, Player player) {
		if (player.getRights() == 2)
			return true;
		if (player.getRights() == 7)
			return true;
		//22207 100 22209 100 22211 100 22213 100 21971 100 21981 100 21991 100 22001 100 22049 100 22059 100 22069 100 22079 100 
		if (item.getId() == //24456 || item.getId() == 
				22207 
				|| item.getId() == 22209 || item.getId() == 22211
				|| item.getId() == 22213 || item.getId() == 21971 
				|| item.getId() == 21981 || item.getId() == 21991
				|| item.getId() == 22001 || item.getId() == 22049
				|| item.getId() == 22059 || item.getId() == 22069
				|| item.getId() == 22709) {
				//item.getId() == 24457) {
			if ((player.prestigeTokens < 5)) {
				player.sm("You must have a prestige level of 5 to wear this.");
				return false;
			}
		}
		if ((item.getId() == 20769 || item.getId() == 20771)) {
			if (!player.isCompletedFightKiln()) {
				player.getPackets()
						.sendGameMessage(
								"You need to complete the fight kiln minigame at least once to use this cape.");
				return false;
			}
			if (!player.isKilledQueenBlackDragon()) {
				player.getPackets()
						.sendGameMessage(
								"You need to have killed the Queen Black Dragon atleast once to use this cape.");
				return false;
			}
		} else if (item.getId() == 14642 || item.getId() == 14645
				|| item.getId() == 15433 || item.getId() == 15435
				|| item.getId() == 14641 || item.getId() == 15432
				|| item.getId() == 15434) {
			if (!player.getQuestManager().completedQuest(Quests.NOMADS_REQUIEM)) {
				player.getPackets()
						.sendGameMessage(
								"You need to have completed Nomad's Requiem miniquest to use this cape.");
				return false;
			}
		}
		/*
		 * if (itemName.contains("goliath gloves") ||
		 * itemName.contains("spellcaster glove") ||
		 * itemName.contains("swift glove")) { if
		 * (player.getDominionTower().getKilledBossesCount() < 50) {
		 * player.getPackets().sendGameMessage(
		 * "You need to have kill atleast 50 bosses in the Dominion tower to wear these gloves."
		 * ); return true; } }
		 */
		return true;
	}

	public static boolean isTradeable(Item item) {
		if (item.getDefinitions().getName().toLowerCase()
				.contains("flaming skull"))
			return false;
		String name = ItemDefinitions.getItemDefinitions(item.getId())
				.getName().toLowerCase();
		if (name.contains("lucky") || name.contains("flaming skull")
				|| name.contains("abyssal whip (lime)")
				|| name.contains("fist of guthix") || name.contains("pk token")
				|| name.contains("fire cape") || name.contains("tokhaar")
				|| name.contains("defender"))
			return false;
		switch (item.getId()) {
		case 7671:
		case 7673:
		case 20821:
		case 6529:
		case 24155:
		case 20767:
		case 20768:
		case 20748:
		case 20749:
		case 20752:
		case 20753:
		case 20754:
		case 20769:
		case 20770:
		case 20771:
		case 20772:
		case 24154:
		case 7462:
		case 23659:
		case 20786:
		case 20787:
		case 20788:
		case 20789:
		case 20790:
		case 20791:
		case 14936:
		case 14937:
		case 14938:
		case 14939:
		case 13661:
		case 24388:
		case 24376:
		case 24379:
		case 24382:
		case 23732:
		case 24338:
		case 22362:
		case 20054:
		case 2996:
		case 23749:
		case 25386:
		case 25388:
		case 25391:
		case 25394:
		case 20929:
		//case 9470:
		case 22215:
		case 22216:
		case 22217:
		case 22218:
		case 19333:
		//case 23679:
		case 23680:
		case 23681:
		case 23682:
		case 23698:
		case 23030:
		case 24110:
		case 24112:
		case 24114:
		case 24108:
		//case 10394:
		case 13099:
		case 24435:
		case 24431:
		case 24433:
		case 24419:
		case 24418:
		case 24412:
		case 24406:
		case 24329:
		case 24330:
		case 24331:
		case 24332:
		case 24333:
		case 24334:
		case 23782:
		case 23894:
		case 15021:
		case 15022:
		case 15023:
		case 15024:
		case 15025:
		case 15026:
		/*case 22207:
		case 22209:
		case 22211:
		case 22213:
		case 21971:
		case 21981:
		case 21991:
		case 22001:
		case 22049:
		case 22059:
		case 22069:
		case 22079:  */
			return false;
		default:
			return true;
		}
	}
}
